package com.jzsk.variable.center.common.base;

import com.jzsk.variable.center.domain.enums.StatusCodeEnum;
import lombok.Data;
import lombok.EqualsAndHashCode;

/**
 * @author jiangli
 */
@Data
@EqualsAndHashCode(callSuper = true)
public class ServiceException extends RuntimeException {

    private static final long serialVersionUID = -3135153298110657590L;

    public static ServiceException DEFAULT_ERROR = new ServiceException(StatusCodeEnum.系统繁忙.getMessage());

    private Integer code;
    private String message;

    /**
     * 构造函数
     *
     * @param message 异常信息
     */
    public ServiceException(String message) {
        this.code = StatusCodeEnum.系统繁忙.getCode();
        this.message = message;
    }

    /**
     * 构造函数
     *
     * @param code    状态码
     * @param message 状态描述
     */
    public ServiceException(Integer code, String message) {
        this.code = code;
        this.message = message;
    }

    /**
     * 构造函数
     *
     * @param statusCodeEnum 状态枚举
     */
    public ServiceException(StatusCodeEnum statusCodeEnum) {
        this.code = statusCodeEnum.getCode();
        this.message = statusCodeEnum.getMessage();
    }
}
